<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>变量类型</title>
  <style>
    *,
    *::after,
    *::before {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    :root {
      min-height: 100vh;
    }

    :root:focus-within {
      scroll-behavior: smooth;
    }

    body {
      min-height: inherit;
    }
  </style>
</head>

<body>
  <img src="./img/1glsl的变量和类型.jpg" alt="">
</body>
<script>
  "use strict"; {
    /* 
      标量:
        float myFloat = 1.0;
        将数值转为布尔类型
        bool myBool = bool(myFloat);
    */

    /* 
      向量:
        vec4 myv4 = vec4(1.0)       myv4 = {1.0,1.0,1.0,1.0}
        vec2 myv2 = vec2(1.0,0.5)   myv2 = {1.0,0.5}
        vec2 temp = vec2(myv2)      temp= {1.0,0.5}
        myv4 = vec4(myv2,temp,0.0);

        向量和矩阵的计算是逐分量进行的，因此，也可以采用下面这两个方法
        vec3 myv3 = myv2.xyx  通过分量访问符 myc3 = {1.0,0.5,1.0}
        vec3 myvb = vec3(myv2[0],myv2[1],myv2[0]); 通过数组 myvb = {1.0,0.5,1.0}
    */

    /* 
      矩阵:
        mat3 my3 = mat3(
          1.0,0.0,0.0,  //第一列矩阵
          0.0,1.0,0.0,  //第二列矩阵
          0.0,1.0,1.0   //第三列矩阵
        );

        my4 = {
          1.0,0.0,0.0,0.0,
          1.0,0.0,0.0,0.0,
        }
        my4 = mat4(1.0);
    */
  };
</script>

</html>